]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
StEntry: add a hook to set the cursor from libgnome-shell
authorGiovanni Campagna <gcampagn@redhat.com>
Wed, 11 Sep 2013 16:11:55 +0000 (18:11 +0200)
committerGiovanni Campagna <gcampagn@redhat.com>
Thu, 12 Sep 2013 08:34:25 +0000 (10:34 +0200)
We need to call into MetaScreen to set the cursor, but we can't
do that from libst, so add a hook that libgnome-shell can fill,
and remove more ClutterX11 usage.

https://bugzilla.gnome.org/show_bug.cgi?id=707467

src/shell-global.c
src/st/st-entry.c
src/st/st-entry.h

index 97cdebd2c9a2b68322fa03696598780f50ac7d02..3f85ac5013d095f61e775590298069e08da44919 100644 (file)
@@ -828,6 +828,16 @@ gnome_shell_gdk_event_handler (GdkEvent *event_gdk,
   gtk_main_do_event (event_gdk);
 }
 
+static void
+entry_cursor_func (StEntry  *entry,
+                   gboolean  use_ibeam,
+                   gpointer  user_data)
+{
+  ShellGlobal *global = user_data;
+
+  meta_screen_set_cursor (global->meta_screen, use_ibeam ? META_CURSOR_IBEAM : META_CURSOR_DEFAULT);
+}
+
 void
 _shell_global_set_plugin (ShellGlobal *global,
                           MetaPlugin  *plugin)
@@ -878,6 +888,7 @@ _shell_global_set_plugin (ShellGlobal *global,
     }
 
   st_im_text_set_event_window (global->ibus_window);
+  st_entry_set_cursor_func (entry_cursor_func, global);
 
   g_signal_connect (global->stage, "notify::width",
                     G_CALLBACK (global_stage_notify_width), global);
index c00caa47ac78b138e2201b5587217d48e807d595..8fec0f4e859f5939eeec6950d302416e591faff9 100644 (file)
 #include "st-clipboard.h"
 #include "st-private.h"
 
-#include <clutter/x11/clutter-x11.h>
-#include <X11/Xlib.h>
-#include <X11/cursorfont.h>
-
 #include "st-widget-accessible.h"
 
 #define HAS_FOCUS(actor) (clutter_actor_get_stage (actor) && clutter_stage_get_key_focus ((ClutterStage *) clutter_actor_get_stage (actor)) == actor)
@@ -681,33 +677,28 @@ st_entry_key_focus_in (ClutterActor *actor)
   clutter_actor_grab_key_focus (priv->entry);
 }
 
+static StEntryCursorFunc cursor_func;
+static gpointer          cursor_func_data;
+
+/**
+ * st_entry_set_cursor_func: (skip)
+ *
+ * This function is for private use by libgnome-shell.
+ * Do not ever use.
+ */
+void
+st_entry_set_cursor_func (StEntryCursorFunc func,
+                          gpointer          data)
+{
+  cursor_func = func;
+  cursor_func_data = data;
+}
+
 static void
 st_entry_set_cursor (StEntry  *entry,
                      gboolean  use_ibeam)
 {
-  Display *dpy;
-  ClutterActor *stage, *actor = CLUTTER_ACTOR (entry);
-  Window wid;
-  static Cursor ibeam = None;
-
-  dpy = clutter_x11_get_default_display ();
-  stage = clutter_actor_get_stage (actor);
-
-  if (stage == NULL)
-    {
-      g_warn_if_fail (!entry->priv->has_ibeam);
-      return;
-    }
-
-  wid = clutter_x11_get_stage_window (CLUTTER_STAGE (stage));
-
-  if (ibeam == None)
-    ibeam = XCreateFontCursor (dpy, XC_xterm);
-
-  if (use_ibeam)
-    XDefineCursor (dpy, wid, ibeam);
-  else
-    XUndefineCursor (dpy, wid);
+  cursor_func (entry, use_ibeam, cursor_func_data);
 
   entry->priv->has_ibeam = use_ibeam;
 }
index ebe95bf44c340132a1ea975ed2463d1948197187..bc79db4ecbeaee465da8bab1188a2980188b2443 100644 (file)
@@ -86,6 +86,10 @@ void            st_entry_set_primary_icon   (StEntry        *entry,
 void            st_entry_set_secondary_icon (StEntry        *entry,
                                              ClutterActor   *icon);
 
+typedef void (*StEntryCursorFunc) (StEntry *entry, gboolean use_ibeam, gpointer data);
+void            st_entry_set_cursor_func    (StEntryCursorFunc func,
+                                             gpointer          user_data);
+
 G_END_DECLS
 
 #endif /* __ST_ENTRY_H__ */